<template>
  <div>
     <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片试图 -->
    <el-card>
      <el-input  style="width: 30%" placeholder="请输入内容"  class="input-with-select">
       <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <!-- 表格区域 -->
      <el-table border stripe :data="orders">
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column  label="订单编号" prop="order_number"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status === '1'" type="success">已付款</el-tag>
            <el-tag v-else type="danger">未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scope">
            {{scope.row.create_time | formatDate}}
          </template>
        </el-table-column>
        <el-table-column prop="order_number" label="操作" width="200">
          <template>
            <el-button size="mini" type="primary" @click="editAddressialogVisible=true">修改地址</el-button>
            <el-button size="mini" type="success" @click="show">物流进度</el-button>
         </template>
        </el-table-column>
        </el-table>
    </el-card>
    <!-- 对会框 -->
    <el-dialog
      title="提示"
      :visible.sync="editAddressialogVisible"
      width="50%">
       <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="省市区/县:">
         <el-cascader
          v-model="form.cityValue"
          :options="cityData"
          @change="cascaderhandleChange">
          </el-cascader>
        </el-form-item>
        <el-form-item label="详细地址">
          <el-input ></el-input>
        </el-form-item>
        </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editAddressialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="editAddressialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 查看物流进度对话框 -->
    <el-dialog
      title="提示"
      :visible.sync="expressProgressDialogVisible"
      width="50%">
      <el-timeline :reverse="false">
        <el-timeline-item
          v-for="(item, index) in expressList"
          :key="index"
          :timestamp="item.time">
          {{item.content}}
        </el-timeline-item>
      </el-timeline>
    </el-dialog>
  </div>
</template>

<script>
import cityData from '../views/citydata'
export default {
  data () {
    return {
      querdate: {
        pagesize: 10,
        pagenum: 1,
        query: ''
        // 给后台传的参数
      },
      // 接受总条数
      total: 0,
      orders: [],
      // 接受订单列表数据
      form: {
        cityValue: []
      },
      editAddressialogVisible: false,
      expressProgressDialogVisible: false,
      cityData: cityData,
      expressList: []

    }
  },

  created () {
    this.getOrders()
  },

  methods: {
    async getOrders () {
      const { data: res } = await this.$axios.get('orders', {
        params: this.querdate
      })
      if (res.meta.status !== 200) return this.$message.error('获取数据失败')
      this.orders = res.data.goods
      this.total = res.data.total
    },
    cascaderhandleChange () {

    },
    async show () {
      this.expressProgressDialogVisible = true
      const { data: res } = await this.$axios.get('http://localhost:8080/api/express')
      console.log(res)
      if (res.meta.status !== 200) return this.$message.error('获取数据失败')
      this.expressList = res.data
    }
  }
}
</script>

<style scoped lang='less'>

</style>
